import { login } from '@/api/login'

const user = {
    state: {
        user: ''
    },
    actions: {
        // 登录
        Login({ commit }, userInfo) {
            //const rememberMe = userInfo.rememberMe
            return new Promise((resolve, reject) => {
                login(userInfo.username, userInfo.password).then(res => {
                    // setToken(res.token, rememberMe)
                    // commit('SET_TOKEN', res.token)
                    // setUserInfo(res.user, commit)
                    // 第一次加载菜单时用到， 具体见 src 目录下的 permission.js
                    //commit('SET_LOAD_MENUS', true)
                    window.sessionStorage.setItem('EL-ADMIN-TOEKN',res.token)
                    resolve()
                }).catch(error => {
                    reject(error)
                })
            })
        },
    }
}

export default user